package leetcode;

public class _0713 {
    /**
     *乘积小于 K 的子数组
     */
    class Solution {
        public int numSubarrayProductLessThanK(int[] nums, int k) {
            if(k<=1){
                return 0;
            }
            int n = nums.length;
            int left =0;
            int ans =0;
            int sum =1;
            for(int right =0;right<n;right++){
                sum *=nums[right];
                while(sum>=k){
                    sum /=nums[left];
                    left++;
                }
                ans+=right-left+1;
            }
            return ans;
        }
    }
}
